﻿package mortal.game.view.vip.panel
{
    import Message.Public.*;
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import mortal.common.display.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.mvc.core.*;

    public class VipTabCellRenderer extends GCellRenderer
    {
        private var _index:int = -1;
        private var _levelTxt:BitmapNumberText;
        private var _isLoad:Boolean;
        private var _vip:GBitmap;
        private var _level:int;

        public function VipTabCellRenderer()
        {
            return;
        }// end function

        override protected function initSkin() : void
        {
            var _loc_1:* = GlobalClass.getBitmap(BitmapDataConst.AlphaBMD);
            if (this._index == -1 || !this._isLoad)
            {
                this.setStyle("downSkin", _loc_1);
                this.setStyle("overSkin", _loc_1);
                this.setStyle("upSkin", _loc_1);
                this.setStyle("selectedDownSkin", _loc_1);
                this.setStyle("selectedOverSkin", _loc_1);
                this.setStyle("selectedUpSkin", _loc_1);
                return;
            }
            var _loc_2:* = GlobalClass.getBitmap(ImagesConst.VipSelectSkin);
            this.setStyle("downSkin", _loc_2);
            this.setStyle("overSkin", _loc_2);
            this.setStyle("upSkin", _loc_1);
            this.setStyle("selectedDownSkin", _loc_2);
            this.setStyle("selectedOverSkin", _loc_2);
            this.setStyle("selectedUpSkin", _loc_2);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseChildren = false;
            this.mouseEnabled = true;
            this.buttonMode = true;
            this._levelTxt = UIFactory.bitmapNumberText(49, 7, "VipLevelNum.png", 17, 20, -7, this, 9);
            this._vip = UIFactory.gBitmap("", 22, 7, this);
            NetDispatcher.addCmdListener(ServerCommand.VipLevelUp, this.updateEffect);
            NetDispatcher.addCmdListener(ServerCommand.VipFreeInfoUpdate, this.updateEffect);
            NetDispatcher.addCmdListener(ServerCommand.VipRewardGet, this.updateEffect);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._levelTxt.dispose(param1);
            this._levelTxt = null;
            this._vip.dispose(param1);
            this._vip = null;
            this._index = -1;
            super.disposeImpl(param1);
            return;
        }// end function

        private function showSkin() : void
        {
            if (isDisposed)
            {
                return;
            }
            this._isLoad = true;
            this.initSkin();
            this._vip.bitmapData = GlobalClass.getBitmapData(ImagesConst.VipTitleTxt);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            this._level = param1.level;
            if (this._index == param1.level)
            {
                return;
            }
            this._index = this._level;
            this._levelTxt.text = this._level.toString();
            this.updateEffect();
            LoaderHelp.addResCallBack(ResFileConst.vipPanel, this.showSkin);
            return;
        }// end function

        private function updateEffect(param1:Object = null) : void
        {
            var _loc_2:* = Cache.instance.vip.level;
            var _loc_3:* = Cache.instance.vip.getVipFreeTimesByType(EVipRecordType._EVipRecordTypeDailyGift);
            var _loc_4:* = 1 - _loc_3;
            if (_loc_2 > 0 && (_loc_2 >= this._level && !Cache.instance.vip.getRewardDic[this._level] || this._level == _loc_2 && _loc_4))
            {
                EffectManager.glowFilterReg(this._levelTxt);
                EffectManager.glowFilterReg(this._vip);
            }
            else
            {
                EffectManager.glowFilterUnReg(this._levelTxt);
                EffectManager.glowFilterUnReg(this._vip);
            }
            return;
        }// end function

    }
}
